home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / borland / tpwn31.zip / PASCAL.ZIP / COMMDLG.PAS < prev    next >
Pascal/Delphi Source File  |  1992-04-06  |  12KB  |  355 lines

  1.  
  2. {*******************************************************}
  3. {                                                       }
  4. {       Turbo Pascal for Windows Run-time Library       }
  5. {       Windows 3.1 API Interface Unit                  }
  6. {                                                       }
  7. {       Copyright (c) 1992 Borland International        }
  8. {                                                       }
  9. {*******************************************************}
  10.  
  11. unit CommDlg;
  12.  
  13. interface
  14.  
  15. uses WinTypes;
  16.  
  17. type
  18.   POpenFilename = ^TOpenFilename;
  19.   TOpenFilename = record
  20.     lStructSize: Longint;
  21.     hWndOwner: HWnd;
  22.     hInstance: THandle;
  23.     lpstrFilter: PChar;
  24.     lpstrCustomFilter: PChar;
  25.     nMaxCustFilter: Longint;
  26.     nFilterIndex: Longint;
  27.     lpstrFile: PChar;
  28.     nMaxFile: Longint;
  29.     lpstrFileTitle: PChar;
  30.     nMaxFileTitle: Longint;
  31.     lpstrInitialDir: PChar;
  32.     lpstrTitle: PChar;
  33.     Flags: Longint;
  34.     nFileOffset: Word;
  35.     nFileExtension: Word;
  36.     lpstrDefExt: PChar;
  37.     lCustData: Longint;
  38.     lpfnHook: function (Wnd: HWnd; Msg, wParam: Word; lParam: Longint): Word;
  39.     lpTemplateName: PChar;
  40.   end;
  41.  
  42. function GetOpenFileName(var OpenFile: TOpenFilename): Bool;
  43. function GetSaveFileName(var OpenFile: TOpenFilename): Bool;
  44. function GetFileTitle(FileName, Title: PChar; TitleSize: Word): Integer;
  45.  
  46. const
  47.   ofn_ReadOnly = $00000001;
  48.   ofn_OverWritePrompt = $00000002;
  49.   ofn_HideReadOnly = $00000004;
  50.   ofn_NoChangeDir = $00000008;
  51.   ofn_ShowHelp = $00000010;
  52.   ofn_EnableHook = $00000020;
  53.   ofn_EnableTemplate = $00000040;
  54.   ofn_EnableTemplateHandle = $00000080;
  55.   ofn_NoValidate = $00000100;
  56.   ofn_AllowMultiSelect = $00000200;
  57.   ofn_ExtentionDifferent = $00000400;
  58.   ofn_PathMustExist = $00000800;
  59.   ofn_FileMustExist = $00001000;
  60.   ofn_CreatePrompt = $00002000;
  61.   ofn_ShareAware = $00004000;
  62.   ofn_NoReadOnlyReturn = $00008000;
  63.   ofn_NoTextFileCreate = $00010000;
  64.  
  65. { Return values for the registered message sent to the hook function
  66.   when a sharing violation occurs.  ofn_ShareFallThrough allows the
  67.   filename to be accepted, ofn_ShareNoWarn rejects the name but puts
  68.   up no warning (returned when the app has already put up a warning
  69.   message), and ofn_ShareWarn puts up the default warning message
  70.   for sharing violations.
  71.  
  72.   Note:  Undefined return values map to ofn_ShareWarn. }
  73.  
  74.   ofn_ShareFallThrough = 2;
  75.   ofn_ShareNoWarn = 1;
  76.   ofn_ShareWarn = 0;
  77.  
  78. type
  79.   PChooseColor = ^TChooseColor;
  80.   TChooseColor = record
  81.     lStructSize: Longint;
  82.     hWndOwner: HWnd;
  83.     hInstance: HWnd;
  84.     rgbResult: Longint;
  85.     lpCustColors: PLongint;
  86.     Flags: Longint;
  87.     lCustData: Longint;
  88.     lpfnHook: function (Wnd: HWnd; Message, wParam: Word;
  89.      lParam: Longint): Word;
  90.     lpTemplateName: PChar;
  91.   end;
  92.  
  93. function ChooseColor(var CC: TChooseColor): Bool;
  94.  
  95. const
  96.   cc_RGBInit = $00000001;
  97.   cc_FullOpen = $00000002;
  98.   cc_PreventFullOpen = $00000004;
  99.   cc_ShowHelp = $00000008;
  100.   cc_EnableHook = $00000010;
  101.   cc_EnableTemplate = $00000020;
  102.   cc_EnableTemplateHandle = $00000040;
  103.  
  104. type
  105.   PFindReplace = ^TFindReplace;
  106.   TFindReplace = record
  107.     lStructSize: Longint;        { size of this struct $20 }
  108.     hWndOwner: HWnd;              { handle to owner's window }
  109.     hInstance: THandle;           { instance handle of.EXE that
  110.                                    contains cust. dlg. template }
  111.     Flags: Longint;              { one or more of the fr_?? }
  112.     lpstrFindWhat: PChar;        { ptr. to search string    }
  113.     lpstrReplaceWith: PChar;     { ptr. to replace string   }
  114.     wFindWhatLen: Word;          { size of find buffer      }
  115.     wReplaceWithLen: Word;       { size of replace buffer   }
  116.     lCustData: Longint;          { data passed to hook fn.  }
  117.     lpfnHook: function (Wnd: HWnd; Msg, wParam: Word; lParam: Longint): Word;
  118.                                  { ptr. to hook fn. or nil }
  119.     lpTemplateName: PChar;       { custom template name     }
  120.   end;
  121.  
  122. const
  123.   fr_Down = $00000001;
  124.   fr_WholeWord = $00000002;
  125.   fr_MatchCase = $00000004;
  126.   fr_FindNext = $00000008;
  127.   fr_Replace = $00000010;
  128.   fr_ReplaceAll = $00000020;
  129.   fr_DialogTerm = $00000040;
  130.   fr_ShowHelp = $00000080;
  131.   fr_EnableHook = $00000100;
  132.   fr_EnableTemplate = $00000200;
  133.   fr_NoUpDown = $00000400;
  134.   fr_NoMatchCase = $00000800;
  135.   fr_NoWholeWord = $00001000;
  136.   fr_EnableTemplateHandle = $00002000;
  137.   fr_HideUpDown = $00004000;
  138.   fr_HideMatchCase = $00008000;
  139.   fr_HideWholeWord = $00010000;
  140.  
  141. function FindText(var FindReplace: TFindReplace): HWnd;
  142. function ReplaceText(var FindReplace: TFindReplace): HWnd;
  143.  
  144. type
  145.   PChooseFont = ^TChooseFont;
  146.   TChooseFont = record
  147.     lStructSize: Longint;       { }
  148.     hWndOwner: HWnd;             { caller's window handle   }
  149.     hDC: HDC;                    { printer DC/IC or nil    }
  150.     lpLogFont: PLogFont;        { ptr. to a LOGFONT struct }
  151.     iPointSize: Integer;                { 10 * size in points of selected font }
  152.     Flags: Longint;             { enum. type flags          }
  153.     rgbColors: Longint;         { returned text color       }
  154.     lCustData: Longint;         { data passed to hook fn.  }
  155.     lpfnHook: function (Wnd: HWnd; Msg, wParam: Word; lParam: Longint): Word;
  156.                                 { ptr. to hook function    }
  157.     lpTemplateName: PChar;      { custom template name     }
  158.     hInstance: THandle;          { instance handle of.EXE that
  159.                                   contains cust. dlg. template }
  160.     lpszStyle: PChar;           { return the style field here
  161.                                   must be lf_FaceSize or bigger }
  162.     nFontType: Word;            { same value reported to the EnumFonts
  163.                                   call back with the extra fonttype_
  164.                                   bits added }
  165.     nSizeMin: Integer;          { minimum pt size allowed & }
  166.     nSizeMax: Integer;          { max pt size allowed if
  167.                                   cf_LimitSize is used      }
  168.   end;
  169.  
  170. function ChooseFont(var ChooseFond: TChooseFont): Bool;
  171.  
  172. const
  173.   cf_ScreenFonts = $00000001;
  174.   cf_PrinterFonts = $00000002;
  175.   cf_Both = cf_ScreenFonts or cf_PrinterFonts;
  176.   cf_ShowHelp = $00000004;
  177.   cf_EnableHook = $00000008;
  178.   cf_EnableTemplate = $00000010;
  179.   cf_EnableTemplateHandle = $00000020;
  180.   cf_InitToLogfontStruct = $00000040;
  181.   cf_UseStyle = $00000080;
  182.   cf_Effects = $00000100;
  183.   cf_Apply = $00000200;
  184.   cf_AnsiOnly = $00000400;
  185.   cf_NoVectorFonts = $00000800;
  186.   cf_NoOEMFonts = cf_NoVectorFonts;
  187.   cf_NoSimulations = $00001000;
  188.   cf_LimitSize = $00002000;
  189.   cf_FixedPitchOnly = $00004000;
  190.   cf_WYSIWYG = $00008000; { must also have cf_ScreenFonts & cf_PrinterFonts }
  191.   cf_ForceFontExist = $00010000;
  192.   cf_ScalableOnly = $00020000;
  193.   cf_TTOnly = $00040000;
  194.   cf_NoFaceSel = $00080000;
  195.   cf_NoStyleSel = $00100000;
  196.   cf_NoSizeSel = $00200000;
  197.  
  198. { these are extra nFontType bits that are added to what is returned to the
  199.   EnumFonts callback routine }
  200.  
  201.   Simulated_FontType = $8000;
  202.   Printer_FontType = $4000;
  203.   Screen_FontType = $2000;
  204.   Bold_FontType = $0100;
  205.   Italic_FontType = $0200;
  206.   Regular_FontType = $0400;
  207.  
  208.   wm_ChooseFont_GetLogfont = wm_User + 1;
  209.  
  210.  
  211. { strings used to obtain unique window message for communication
  212.   between dialog and caller }
  213.  
  214.   LBSelChString = 'commdlg_LBSelChangedNotify';
  215.   ShareViString = 'commdlg_ShareViolation';
  216.   FileOKString = 'commdlg_FileNameOK';
  217.   ColorOKString = 'commdlg_ColorOK';
  218.   SetRGBString = 'commdlg_SetRGBColor';
  219.   FindMsgString = 'commdlg_FindReplace';
  220.   HelpMsgString = 'commdlg_help';
  221.  
  222. { HIWORD values for lParam of commdlg_LBSelChangeNotify message }
  223.  
  224. const
  225.   cd_LBSelNoItems = -1;
  226.   cd_LBSelChange  = 0;
  227.   cd_LBSELSUB     = 1;
  228.   cd_LBSelAdd     = 2;
  229.  
  230. type
  231.   PPrintDlg = ^TPrintDlg;
  232.   TPrintDlg = record
  233.     lStructSize: Longint;
  234.     hWndOwner: HWnd;
  235.     hDevMode: THandle;
  236.     hDevNames: THandle;
  237.     hDC: HDC;
  238.     Flags: Longint;
  239.     nFromPage: Word;
  240.     nToPage: Word;
  241.     nMinPage: Word;
  242.     nMaxPage: Word;
  243.     nCopies: Word;
  244.     hInstance: THandle;
  245.     lCustData: L